package com.dyzx.hbb.modules.wms.controller;


import com.dyzx.hbb.common.config.MyLambdaQueryWrapper;
import com.dyzx.hbb.common.controller.BaseValidController;
import com.dyzx.hbb.modules.wms.entity.WmsStockTakes;
import com.dyzx.hbb.modules.wms.query.WmsStockTakesQuery;
import com.dyzx.hbb.modules.wms.service.WmsStockTakesService;
import com.dyzx.hbb.modules.wms.vo.WmsStockTakesUVO;
import com.dyzx.hbb.modules.wms.vo.WmsStockTakesVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 库存调拨单管理控制器
 * <p>处理仓库管理系统中库存调拨单的创建、查询和管理业务逻辑
 * <p>主要职责：
 * <ul>
 * <li>提供库存调拨单的基础CRUD操作</li>
 * <li>支持按调拨单号、仓库ID、货位ID、区域ID和状态等条件筛选调拨单信息</li>
 * <li>维护库存调拨单数据的排序展示</li>
 * </ul>
 * <p>设计意图：为仓库管理模块提供库存调拨单的数据管理接口，
 * 确保库存调拨业务的可追踪性和准确性
 * 
 * @author 开发团队
 * @version 1.0.0
 * @since 2023-05-30
 */
@Tag(name = "库存调拨单管理", description = "库存调拨单相关接口")
@RestController
@RequestMapping("/wms/stock/takes")
public class WmsStockTakesController extends BaseValidController<
        WmsStockTakesService,
        WmsStockTakes,
        WmsStockTakesQuery,
        WmsStockTakesVO,
        WmsStockTakesUVO
        > {

    @Autowired
    private WmsStockTakesService service;

    @Override
    protected WmsStockTakesService getBaseService() {
        return service;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsStockTakes> queryWrapper(WmsStockTakesQuery query) {
        MyLambdaQueryWrapper<WmsStockTakes> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsStockTakes::getCreateDate);

        if (query != null) {
            queryWrapper.likeRight(StringUtils.isNotBlank(query.getNo()), WmsStockTakes::getNo, query.getNo())
                    .eq(query.getLocation_id() != null, WmsStockTakes::getLocationId, query.getLocation_id())
                    .eq(query.getLocation_area_id() != null, WmsStockTakes::getLocationAreaId, query.getLocation_area_id())
                    .eq(query.getStatus() != null, WmsStockTakes::getStatus, query.getStatus())
                    .eq(query.getHouse_id() != null, WmsStockTakes::getHouseId, query.getHouse_id());
        }
        return queryWrapper;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsStockTakes> queryInfoWrapper() {
        MyLambdaQueryWrapper<WmsStockTakes> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsStockTakes::getCreateDate);
        return queryWrapper;
    }

    @Override
    protected WmsStockTakes addValid(WmsStockTakesVO entity) {
        return null;
    }

    @Override
    protected WmsStockTakes editValid(WmsStockTakesUVO entity) {
        return null;
    }
}